import { operationType, cascaderType } from '@/config/dict.js'
export const formItem = change => {
	return [
		{
			type: 'radioGroup',
			key: 'radioGroup',
			label: '',
			radios: [
				{ label: 'me', name: '我的' },
				{ label: 'all', name: '全部' },
				{ label: 'pending', name: '待审核' }
			],
			otherAttrs: {
				placeholder: '请输入操作内容',
				clearable: true
			},
			slotListeners: {
				change: change
			}
		},
		{
			type: 'input',
			key: 'keyword',
			label: '请输入标题',
			otherAttrs: {
				placeholder: '请输入操作内容',
				clearable: true
			}
		},
		{
			type: 'datePick',
			key: 'beginDate',
			label: '日期',
			otherAttrs: {
				style: {
					// width: '100%',
				},
				placeholder: '选择日期',
				// type: "daterange", // date week month year dates daterange monthrange
				format: 'yyyy 年 MM 月 dd 日', // 有或者没有
				// valueFormat: "",// 三种 yyyy 年 MM 月 dd 日 --- yyyy-MM-dd -- timestamp
				// rangeSeparator: "至",
				// startPlaceholder: "开始月份",
				// endPlaceholder: "结束月份",
				// defaultValue: new Date(),
				unlinkPanels: true, // 日期范围时，左右面板会联动

				editable: false,
				clearable: true,
				size: 'small' // large, small, mini
			}
		},
		{
			type: 'select',
			key: 'operationType',
			options: operationType,
			label: '请选择状态',
			otherAttrs: {
				placeholder: '请选择类型',
				clearable: true,

				filterable: true // 搜索功能
			}
		},
		{
			type: 'cascader',
			key: 'cascaderType',
			options: cascaderType,
			label: '请选择状态',
			otherAttrs: {
				placeholder: '请选择类型',
				// disabled: true,
				clearable: true,
				// collapseTags: true, // 多选合并显示
				// custom: false, // 自定义模板
				// filterable: true, // 搜索功能
				// multipleLimit: 2, // 限制选中的个数
				// allowCreate: true, // 创建条目，貌似没什么用，保留
				// defaultFirstOption: true, //回车选择第一个
				// reserveKeyword: true,// 多选且可搜索时,保留当前的搜索关键词
				separator: '/', // 选项的分隔符
				props: { expandTrigger: 'hover' } // { expandTrigger: 'hover', multiple: true, checkStrictly: true }
			},
			slotListeners: {
				// change: e, // 发生改变
				// blur: e, // 失去焦点时
				// focus: e, // 获得焦点时
			}
		}
	]
}
// const formarData = (h, scope) => {
//   return scope.row[h]
// }
export const tableColumn = (page, size, dropdownClick, handleLink) => {
	return [
		{
			key: 'date',
			attrs: {
				label: '日期',
				resizable: false,
				align: 'center',
				minWidth: 110
			}
		},
		{
			key: 'number',
			attrs: {
				label: '项目编号',
				minWidth: 80,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'name',
			attrs: {
				label: '检测项目名称',
				minWidth: 150,
				align: 'center',
				resizable: false
			},
			render(h, scope) {
				return (
					<el-link
						type="primary"
						underline={false}
						onClick={() => {
							handleLink(scope.row)
						}}
					>
						{scope.row.name}
					</el-link>
				)
			}
		},
		{
			key: 'clientName',
			attrs: {
				label: '客户名称',
				minWidth: 100,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'type',
			attrs: {
				label: '项目类型',
				minWidth: 100,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'accountNumber',
			attrs: {
				label: '账号数量',
				minWidth: 80,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'section',
			attrs: {
				label: '部门',
				minWidth: 100,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'proposer',
			attrs: {
				label: '申请人',
				minWidth: 80,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'status',
			attrs: {
				label: '状态',
				minWidth: 80,
				align: 'center',
				resizable: false
			}
		},
		{
			key: 'operate',
			attrs: {
				label: '操作',
				resizable: false, // 列拖动
				align: 'center',
				minWidth: 100
			},
			render: (h, scope) => {
				return (
					<el-dropdown
						onCommand={e => {
							dropdownClick(e, scope.row)
						}}
					>
						<el-button type="primary" size="small">
							操作<i class="el-icon-arrow-down el-icon--right"></i>
						</el-button>
						<el-dropdown-menu slot="dropdown">
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status1' && scope.row['status1'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-view" command="1">
											查看
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status2' && scope.row['status2'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-edit" command="2">
											编辑
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status3' && scope.row['status3'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-delete" command="3">
											删除
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status4' && scope.row['status4'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-position" command="4">
											提交
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status5' && scope.row['status5'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-refresh-left" command="5">
											撤销
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status6' && scope.row['status6'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-thumb" command="6">
											签收
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status7' && scope.row['status7'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-aim" command="7">
											审核
										</el-dropdown-item>
									)
								}
							})}
							{Reflect.ownKeys(scope.row).map(key => {
								if (key == 'status8' && scope.row['status8'] == 1) {
									return (
										<el-dropdown-item icon="el-icon-close" command="8">
											关闭
										</el-dropdown-item>
									)
								}
							})}
						</el-dropdown-menu>
					</el-dropdown>
				)
			}
		}
	]
}
